package com.blogs.component;

import java.util.ArrayList;

import com.blogs.component.CommentAdapter.ViewHolder;
import com.blogs.entity.CommentFeed;
import com.blogs.entity.CommentQueueFeed;
import com.blogs.tools.DBSharedPreferences;
import com.cnblogs.R;
import com.cnblogs.R.color;


import android.app.Activity;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

public class CommentQueueAdapter extends BaseAdapter{
	private  ArrayList<CommentQueueFeed> feedList = null;
	private ViewHolder holder;
	private Activity context = null;
	private DBSharedPreferences sp;
	public CommentQueueAdapter(Activity context, ArrayList<CommentQueueFeed> feedList) {
		// TODO Auto-generated constructor stub
		this.context = context;
		this.feedList = feedList;
		sp= new DBSharedPreferences(context);
	}
	public int getCount() {
		// TODO Auto-generated method stub
		return feedList.size();
	}
	public Object getItem(int position) {
		// TODO Auto-generated method stub
		return feedList.get(position);
	}
	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return position;
	}
	public View getView(int position, View convertView, ViewGroup parent) {
		// TODO Auto-generated method stub
		if (convertView == null ) {
			convertView = View.inflate(context, R.layout.comment_queue_adapter,null);
			holder=new ViewHolder();
			holder.com_que_text_tv=(TextView)convertView.findViewById(R.id.com_que_text_tv);
			holder.com_que_errtext_tv=(TextView)convertView.findViewById(R.id.com_que_errtext_tv);
			holder.com_que_time_tv=(TextView)convertView.findViewById(R.id.com_que_time_tv);
			convertView.setTag(holder);
		}
		else
		{
			holder = (ViewHolder) convertView.getTag();
		}
		if(sp.GetIsDarkState())
		{
			holder.com_que_text_tv.getBackground().setLevel(2);
		}
		else
		{
			holder.com_que_text_tv.getBackground().setLevel(1);
		}
		holder.com_que_text_tv.setText(feedList.get(position).commendBody);
		holder.com_que_errtext_tv.setText(feedList.get(position).err_text);
		holder.com_que_time_tv.setText(feedList.get(position).err_time);
		return convertView;
	}
	class ViewHolder 
	{
		TextView com_que_text_tv;
		TextView com_que_errtext_tv;
		TextView com_que_time_tv;
	}
}
